package com.fjwt.gz.mgr.ctrl.activity;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fjwt.gz.core.model.ApiRes;
import com.fjwt.gz.db.dto.ActivityAwardDTO;
import com.fjwt.gz.db.vo.StatActe017MchVO;
import com.fjwt.gz.db.vo.StatActe017NumVO;
import com.fjwt.gz.db.vo.StatActe017RecordVO;
import com.fjwt.gz.mgr.ctrl.CommonCtrl;
import com.fjwt.gz.service.impl.StatActe017NumService;
import com.fjwt.gz.service.impl.StatActe017RecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ACTE017活动管理 Controller
 */
@RestController
@Slf4j
@RequestMapping("/api/activity/acte017")
public class ACTE017Controller extends CommonCtrl {

    @Autowired
    private StatActe017RecordService statActe017RecordService;

    @Autowired
    private StatActe017NumService statActe017NumService;

    /**
     * 查询 越减越便宜客户参与记录明细表
     * @return
     */
    @PreAuthorize("hasAnyAuthority('ENT_ACTIVITY_LIST_INFO_STATS')")
    @GetMapping(value = "/getFansRecord")
    public ApiRes getFansRecord(){
        ActivityAwardDTO activityAwardDTO = getObject(ActivityAwardDTO.class);
        IPage<StatActe017RecordVO> list = this.statActe017RecordService.getFansRecord(getIPage(),activityAwardDTO);
        return ApiRes.page(list);
    }

    /**
     * 导出 越减越便宜客户参与记录明细表
     * @return
     */
    @PostMapping(value = "/exportFansRecord")
    public ApiRes exportFansRecord(){
        ActivityAwardDTO activityAwardDTO = getObject(ActivityAwardDTO.class);
        this.statActe017RecordService.exportFansRecord(activityAwardDTO);
        return ApiRes.ok();
    }

    /**
     * 查询 越减越便宜 通报表（机构明细）
     * @return
     */
    @GetMapping(value = "/getAgentDetail")
    public ApiRes getAgentDetail(){
        ActivityAwardDTO activityAwardDTO = getObject(ActivityAwardDTO.class);
        IPage<StatActe017NumVO> list =  statActe017NumService.getAgentDetail(getIPage(),activityAwardDTO);
        return ApiRes.ok(list);
    }

    /**
     * 导出 越减越便宜 通报表（机构明细）
     * @return
     */
    @PostMapping(value = "/exportAgentDetail")
    public ApiRes exportAgentDetail(){
        ActivityAwardDTO activityAwardDTO = getObject(ActivityAwardDTO.class);
        statActe017NumService.exportAgentDetail(activityAwardDTO);
        return ApiRes.ok();
    }

    /**
     * 查询 报表名称：“越减越便宜-商户版”活动发展通报
     * @return
     */
    @GetMapping(value = "/getStatMchV")
    public ApiRes getStatMchV(){
        ActivityAwardDTO activityAwardDTO = getObject(ActivityAwardDTO.class);
        StatActe017MchVO statActe017MchVO = this.statActe017NumService.getStatMchV(activityAwardDTO);
//        List<StatActe017MchVO> statActe017MchVO = List.copyOf(list);
        return ApiRes.ok(statActe017MchVO);
    }

    /**
     * 导出 报表名称：“越减越便宜-商户版”活动发展通报
     * @return
     */
    @PostMapping(value = "/exportStatMchV")
    public ApiRes exportStatMchV(){
        ActivityAwardDTO activityAwardDTO = getObject(ActivityAwardDTO.class);
        this.statActe017NumService.exportStatMchV(activityAwardDTO);
        return ApiRes.ok();
    }

}
